package com.example.testanimation.objectanimation;

import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.Shape;

public class ShapeHolder{
	private float x;
	private float y;

	private float width;
	private float height;

	private ShapeDrawable drawable;
	private int color;
	public ShapeHolder() {
		Shape shape = new OvalShape();

		width = 100;
		height = 100;
		shape.resize(width, height);

		drawable = new ShapeDrawable(shape);
		drawable.getPaint().setColor(Color.RED);
	}
	

	
	
	public float getWidth() {
		return width;
	}



	public void setWidth(float width) {
		this.width = width;
		resize();
	}



	private void resize() {
		drawable.getShape().resize(width, height);
	}



	public int getColor() {
		return color;
	}



	public void setHeight(float height) {
		this.height = height;
		resize();
	}


	public ShapeHolder setX(float x){
		this.x = x;
		return this;
	}
	
	public ShapeHolder setY(float y){
		this.y =  y;
		return this;
	}
	
	public float getX() {
		return x;
	}

	public float getY() {
		return y;
	}

	public void setColor(int color){
		drawable.getPaint().setColor(color);
		this.color = color;
	}
	
	public ShapeDrawable getShape(){
		return drawable;
	}

	public int getHeight() {
		return (int) drawable.getShape().getHeight();
	}

	public void setAlpha(float animatedValue) {
		drawable.setAlpha((int) (255 * animatedValue));
	}
	
}